package com.hd.tiyu.yuejian.Fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hd.tiyu.yuejian.Adapter.DashiAdapter;
import com.hd.tiyu.yuejian.JavaBean.Dashi;
import com.hd.tiyu.yuejian.JavaBean.Master;
import com.hd.tiyu.yuejian.Model.ListsModel;
import com.hd.tiyu.yuejian.R;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Administrator on 2017/9/15.
 */

public class DashiFtagment extends Fragment {
    private View view;
    RecyclerView recyclerView;
    List<Dashi> data;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view=inflater.inflate(R.layout.dashitab,container,false);
        initView();
        initEvent();
        initData();
        return view;
    }

    private void initView() {
        recyclerView=view.findViewById(R.id.re_dashilist);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    }

    private void initEvent() {

    }

    private void initData() {
        ListsModel listsmodel=new ListsModel();
        Call<List<Dashi>> call=listsmodel.getlistsMaster();
        call.enqueue(new Callback<List<Dashi>>() {
            @Override
            public void onResponse(Call<List<Dashi>> call, Response<List<Dashi>> response) {
                data=response.body();
                recyclerView.setAdapter(new DashiAdapter(getActivity(),data));
            }
            @Override
            public void onFailure(Call<List<Dashi>> call,Throwable t) {

            }
        });
    }
}
